package com.acwer.drgs.performance.es.config;

import com.acwer.drgs.performance.es.domain.MiniPerformanceInfo;
import org.springframework.data.elasticsearch.core.event.BeforeConvertCallback;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.stereotype.Component;

/**
 * 绩效实体主键生成
 */
@Component
public class MiniPerformanceInfoBeforeConvertCallback implements BeforeConvertCallback<MiniPerformanceInfo> {

    @Override
    public MiniPerformanceInfo onBeforeConvert(MiniPerformanceInfo miniPerformanceInfo, IndexCoordinates indexCoordinates) {
        //索引主键=病案号+住院次数
        miniPerformanceInfo.setId(miniPerformanceInfo.getBah()+miniPerformanceInfo.getZycs());
        return miniPerformanceInfo;
    }
}
